package com.homer.android.activity.device;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.CheckBox;

import com.homer.android.R;
import com.homer.android.sdk.devcie.IEspDevicePlug;

public class DevicePlugActivity extends DeviceActivityAbs implements OnClickListener
{
    private IEspDevicePlug mDevicePlug;
    
    protected CheckBox mPlugSwitch;
    
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        
        mDevicePlug = (IEspDevicePlug)mIEspDevice;
        
        boolean compatibility = isDeviceCompatibility();
        checkHelpModePlug(compatibility);
        if (compatibility)
        {
            executeGet();
        }
    }
    
    @Override
    protected View initControlView()
    {
        View view = getLayoutInflater().inflate(R.layout.device_activity_plug, null);
        mPlugSwitch = (CheckBox)view.findViewById(R.id.plug_switch);
        mPlugSwitch.setOnClickListener(this);
        
        return view;
    }
    
    @Override
    public void onClick(View v)
    {
//        if (v == mPlugSwitch)
//        {
//            boolean isOn = mPlugSwitch.isChecked();
//            EspStatusPlug status = new EspStatusPlug();
//            status.setIsOn(isOn);
//            
//            if (isDeviceArray())
//            {
//                mDevicePlug.setStatusPlug(status);
//            }
//            
//            executePost(status);
//        }
    }
    
    @Override
    protected void executePrepare()
    {
        
    }
    
    @Override
    protected void executeFinish(int command, Object result)
    {
        boolean isOn = mDevicePlug.getStatusPlug().isOn();
        mPlugSwitch.setChecked(isOn);
        
        checkHelpExecuteFinish(command, result);
    }
    
    protected void checkHelpModePlug(boolean compatibility)
    {
    }
    
    protected void checkHelpExecuteFinish(int command, Object result)
    {
    }
}
